#!/usr/bin/env python
#coding:utf-8

import sys

def myurlopen1():
    import urllib.request
    url=r'http://www.python.org'
    response=urllib.request.urlopen(url)
    html=response.read()
    print(html)

def myurlopen2():
    import urllib.request
    url=r'http://www.python.org'
    req=urllib.request.Request(url)
    response=urllib.request.urlopen(req)
    the_page=response.read()
    print(the_page)

def myurlopen4():
    import urllib.request
    url='http://www.pretend_server.org'
    req=urllib.request.Request(url)
    try:
        urllib.request.urlopen(req)
    except urllib.error.URLError as e:
        print(e.reason)

def showerrorcode():
    import http.server
    for k,v in sorted(http.server.BaseHTTPRequestHandler.responses.items()):
        print(k,':',v)

def myurlopen5():
    import urllib.request
    url='http://www.python.org/fish.html'
    req=urllib.request.Request(url)
    try:
        urllib.request.urlopen(req)
    except urllib.error.HTTPError as e:
        print(e.code)
        print(e.read())


def main():
    myurlopen3()


if __name__=='__main__':
    main()
    sys.stdout.write('done\n')
